package uy.com.csi.gestpro.model.ejbbean;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import uy.com.csi.gestpro.model.ejbremote.ClimaEjbRemote;
import uy.com.csi.gestpro.model.mantenimiento.GpClma;

@Stateless
public class ClimaEjb implements ClimaEjbRemote {
	@PersistenceContext(name = "pu_gestpro")
	EntityManager em;

	public ClimaEjb() {
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<GpClma> getClmaLst() {
		List<GpClma> climaLst = null;
		try {
			String consulta = "select c from GpClma c";
			Query q = em.createQuery(consulta);
			climaLst = (List<GpClma>) q.getResultList();
		} catch (Exception e) {
		}
		return climaLst;
	}

	@Override
	public GpClma getClmaById(Integer id) {
		GpClma clima = null;
		try {
			String consulta = "select c from GpClma c where c.id=:id";
			Query q = em.createQuery(consulta);
			q.setParameter("id", id);
			clima = (GpClma) q.getSingleResult();
		} catch (Exception e) {
		}
		return clima;
	}
}
